/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package backing;

import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import officeboost.domain.EquipmentService;
import officeboost.domain.equip_venue.Equipment;

/**
 *
 * @author XJ
 */
@ManagedBean
public class EquipmentBacking {
    @EJB
    private EquipmentService equipmentService;
    private List<Equipment> equList=new ArrayList<>();
    private String numtoborrow;
    private String status;
    public List<Equipment> getEquList() {
        return equList;
    }

    public void setEquList(List<Equipment> equList) {
        this.equList = equList;
    }

    public String getNumtoborrow() {
        return numtoborrow;
    }

    public void setNumtoborrow(String numtoborrow) {
        this.numtoborrow = numtoborrow;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }
    
    public void init(){
        if(equipmentService.findAll()!=null)
            this.setEquList(equipmentService.findAll());
    }
    
    public String equBorrow(){
        Equipment e;
        if((e=equipmentService.find(this.numtoborrow))!=null)
        {
            this.setStatus("The equipment you borrowing is now "+e.getStatus());
            this.equipmentService.use(this.numtoborrow);            
        }
        return "equipment_apply";
    }
}
